#include<bits/stdc++.h>
using namespace std;
long long d[100005],a[100005],vv[100005],p[100005];
long long dd[100005];
long long nn[10005][10005],kk[100005];
long long bzf=0,yry=0;
long long T,n,m,l,v;
long long qwq(int aa){
    if(aa<0) aa=-aa;
    return aa;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect,out","w",stdout);
    cin>>T;
    while(T>0){
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>vv[i]>>a[i];
            d[i]=l-d[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
            p[i]=l-p[i];
        }
        for(int i=1;i<=n;i++){
            if(a[i]==0)
                if(vv[i]>v)
                    for(int j=1;j<=m;j++)
                        if(p[j]<=d[i]){
                            bzf++;
                            break;
                        }
            if(a[i]>0){
                if(vv[i]>v)
                    for(int j=1;j<=m;j++)
                        if(p[j]<=d[i]){
                            bzf++;
                            break;
                        }
                if(vv[i]==v)
                    for(int j=1;j<=m;j++)
                        if(p[j]<d[i]){
                            bzf++;
                            break;
                        }
                dd[i]=d[i]-((v*v-vv[i]*vv[i])/2*a[i]);
                for(int j=1;j<=m;j++)
                    if(p[j]<dd[i]){
                        bzf++;
                        break;
                    }
            }
            if(a[i]<0){
                if(vv[i]<=v) continue;
                dd[i]=d[i]-((vv[i]*vv[i]-v*v)/2*qwq(a[i]));
                if(dd[i]<0) dd[i]=0;
                for(int j=1;j<=m;j++)
                    if(p[j]<=d[i] && p[j]>=dd[i]){
                        bzf++;
                        break;
                    }
            }
        }
        for(int i=1;i<n;i++){
            if(a[i]==0){
                if(vv[i]<=v) continue;
                if(vv[i]>v){
                    for(int j=1;j<=m;j++)
                        if(p[j]<=d[i])
                            nn[i][j]++;
                }
            if(a[i]>0){
                if(vv[i]>v)
                    for(int j=1;j<=m;j++)
                        if(p[j]<=d[i])
                            nn[i][j]++;
                if(vv[i]==v)
                    for(int j=1;j<=m;j++)
                        if(p[j]<d[i])
                            nn[i][j]++;
                dd[i]=d[i]-((v*v-vv[i]*vv[i])/2*a[i]);
                for(int j=1;j<=m;j++)
                    if(p[j]<dd[i])
                        nn[i][j]++;
            }
            if(a[i]<0){
                if(vv[i]<=v) continue;
                dd[i]=d[i]-((vv[i]*vv[i]-v*v)/2*qwq(a[i]));
                if(dd[i]<0) dd[i]=0;
                for(int j=1;j<=m;j++)
                    if(p[j]<=d[i] && p[j]>=dd[i])
                        nn[i][j]++;
                }
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(nn[i][j]==0)
                    kk[j]++;
            }
        }
        for(int j=1;j<=m;j++)
            if(kk[j]==n)
                yry++;
        cout<<bzf<<' '<<yry-1<<endl;
        T--;
    }
    return 0;
}
